<?php
include 'functions.php';
session_start();

$lang = isset($_GET['lang'])?$_GET['lang']:null;
if ($lang == null) die;

$words = array();

foreach ($_POST as $key => $values) {
	$key = urldecode($key);
	if (false === strpos($key, '_old')) {
		$words[$key] = explode(',', $values);
		// echo $key.' ('.urlencode($key).'): '.$values.' <hr/>';
	}
}

file_put_contents(FILENAME.SEPARATOR.$lang.EXTENSION, json_encode($words)); 
header('Location: edit.php?success&lang='.$lang);